<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <!-- <img class="outline-parent-bg" :src="publicUrls + 'free/style8/Auxiliaryoutlinestyle5Bg.webp'" alt="" /> -->
    <div
      class="outline border-hover-style"
      :style="{ backgroundImage: `url(${publicUrls + 'free/style8/Auxiliaryoutlinestyle6Bg.webp'})` }"
    >
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>

      <div
        class="content-box"
        :class="{
          content1:
            (props.info.value || (props.info.video && props.info.video.url)) &&
            !props.info.remarks &&
            props.info.subTitle,
          content2:
            (props.info.value || (props.info.video && props.info.video.url)) &&
            !props.info.remarks &&
            !props.info.subTitle,
          content3:
            !(props.info.value || (props.info.video && props.info.video.url)) &&
            !props.info.remarks &&
            props.info.subTitle,
        }"
      >
        <div
          class="audio-box"
          :class="isPlay && 'audio-rotate'"
          v-if="props.info.audio && props.info.audio.url"
          @click="audioplay(true)"
        >
          <i class="doorIcon">&#xe688;</i>
        </div>
        <div
          class="content-item"
          :style="{ backgroundImage: `url(${publicUrls + 'free/style8/Auxiliaryoutlinestyle6BgCover.webp'})` }"
          v-if="props.info.value || (props.info.video && props.info.video.url)"
        >
          <div class="medium">
            <img
              v-if="props.info.value && !(props.info.video && props.info.video.url)"
              class="outline-cover"
              @click="ImgVisible = true"
              :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
              alt=""
            />
            <videoview @click="audioplay(false)" :info="props.info"></videoview>
          </div>
        </div>
        <div class="top-box">
          <div class="outline-title" v-html="textType(props.info.text)"></div>
        </div>
        <div class="btm-box">
          <p class="outline-subTitle" v-if="props.info.subTitle">
            {{ props.info.subTitle }}
          </p>

          <div
            class="TextMax-box"
            :class="{ 'TextMax-box-1': !props.info.subTitle }"
            v-if="(props.info.value || (props.info.video && props.info.video.url)) && props.info.remarks"
          >
            <TextMax
              v-if="props.domShow"
              :data="props.info.remarks"
              :title="props.info.text"
              :infoData="props.info"
              :row="props.info.subTitle ? 3 : 5"
            ></TextMax>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free8Style2',
});
</script>

<script setup lang="ts">
import { publicUrls, textType } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 220px linear-gradient(transparent, rgba(0, 0, 0, 0.2));
  margin: 0 80px;
}

.outline {
  position: relative;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  margin-top: 50px;
  z-index: 20;
  width: 317px;
  height: 483px;
  display: flex;
  flex-direction: column;
}

.outline-content {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  // flex-shrink: 0;
}
.top-box {
  display: flex;
  justify-content: flex-end;
  height: 240px;
  width: 100%;
  padding-right: 9px;
}
.outline-title {
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;

  ::v-deep p {
    width: 20px;
    height: 100%;
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 10px;
    color: rgba(251, 245, 146, 1);
    text-align: center;
    font-family: 'SourceHanSerifCN-Bold';
    font-size: 20px;
    line-height: 30px;
    color: rgba(251, 245, 146, 1);
    text-shadow: 0px 4px 2px rgba(0, 0, 0, 0.5), 0px -1px 1px rgba(0, 0, 0, 0.15);
    &:nth-child(2) {
      position: relative;
      margin-left: 10px;
    }
  }
}
.content-box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 317px;
  height: 483px;
  padding: 20px 29px 36px 18px;
}
.btm-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 270px;
  margin-top: 26px;
}
.outline-subTitle {
  width: 100%;
  font-family: SourceHanSerifCN;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 24px;
  text-align: center;
  position: relative;
}
.TextMax-box {
  width: 270px;
  margin-top: 17px;
}
.TextMax-box-1 {
  margin-top: 0px;
}
.content-item {
  position: absolute;
  top: 20px;
  left: -67px;
  display: flex;
  //   align-items: center;
  justify-content: center;
  width: 221px;
  height: 246px;
  overflow: hidden;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  padding: 21px 3px;
  padding-right: 10px;
}

.content1 {
}
.content2 {
}
.content3 {
}
// ::v-deep .textMore-box {
//   flex: 1;
// }
.medium {
  width: 202px;
  height: 194px;
  position: relative;
  overflow: hidden;
  &:hover .outline-cover {
    transform: scale(1.2);
  }
  ::v-deep .mask-layer {
    width: 100%;
    height: 100%;
    background: transparent;
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border: 2px solid rgba(255, 255, 255, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: rgba(255, 255, 255, 1);
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    overflow: hidden;
    transition: all 0.3s ease;
  }
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
.audio-box {
  position: absolute;
  bottom: 0px;
  left: 0px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e8e4d9;
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  border: 2px solid #345746;
  &:hover {
    background: rgba(218, 211, 190, 1);
  }
  .doorIcon {
    font-size: 24px;
    color: rgba(52, 87, 70, 1);
  }
}

::v-deep .van-text-ellipsis {
  font-family: PingFangSC !important;
  font-size: 16px !important;
  color: rgba(255, 255, 255, 0.8) !important;
  line-height: 32px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: rgba(255, 255, 255, 1) !important;
  font-weight: 400 !important;
  text-decoration-line: underline;
}
</style>
